package main

import (
	"github.com/veandco/go-sdl2/img"
	"github.com/veandco/go-sdl2/sdl"
)

func main() {
	sdl.Init(sdl.INIT_EVERYTHING)
	defer sdl.Quit()

	window, _ := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
		670, 620, sdl.WINDOW_SHOWN)
	defer window.Destroy()

	surface, _ := window.GetSurface()
	defer surface.Free()
	surface.FillRect(nil, sdl.MapRGB(surface.Format, 0x0, 0x0, 0x0))

	pngImage, _ := img.Load("../asserts/image/texture.png")
	defer pngImage.Free()

	//pngImage.BlitScaled(nil, surface, &sdl.Rect{X: 0, Y: 0, W: 670, H: 620})
	pngImage.Blit(nil, surface, nil)
	window.UpdateSurface()

	running := true
	for running {
		for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
			switch event.(type) {
			case *sdl.QuitEvent:
				println("Quit")
				running = false
				break
			}
		}
		sdl.Delay(16)
	}
}
